#include "LinkTree.h"
#include "MyFileSystem.h"
#include <iostream>
#include <cstring>


using ElementType = void *;

// int Compare(ElementType element1 ,ElementType element2)
// {
//     char *c1 = (char *)element1;
//     char *c2 = (char *)element2;
//     return strcmp(c1,c2);
// }

// void Print(ElementType element1)
// {
//     FlieInfo* f = (FlieInfo *)element1;
//     std::cout<<f->name<<std::endl;
// }



int main(int argc,char* argv[])
{
    // std::string path = "./";
    // if(argc >= 2)
    // {
    //     path = argv[1];
    // }
    // MyFileSystem s(path);
    // s.SetPrint(Print);
    // //s.FindByFileName("1");
    // s.show();


    LinkTree tree;
    // tree.SetCompare(Compare);


    TreeNode* suqian = new TreeNode((ElementType)("苏嵌"));
    suqian->Connect(tree.Getroot());

    TreeNode* class1 = new TreeNode((ElementType)"267班");
    TreeNode* class2 = new TreeNode((ElementType)"268班");
    class1->Connect(suqian);
    class2->Connect(suqian);

    TreeNode* c1 = new TreeNode((ElementType)"张三");
    TreeNode* c2 = new TreeNode((ElementType)"李四");
    TreeNode* c3 = new TreeNode((ElementType)"王五");
    TreeNode* c4 = new TreeNode((ElementType)"赵六");

    c1->Connect(class1);
    c2->Connect(class1);

    c3->Connect(class2);
    c4->Connect(class2);

    int b = tree.GetTreeHight();
    std::cout<<b<<std::endl;
    tree.show();

    // DoubleLinkList list =  tree.FindByElement((ElementType)"李四");
    // TreeNode *stu = (TreeNode*)*list.FindByIndex(0);
    // stu->Disconnect(stu->GetParent());

    // list = tree.FindByElement((ElementType)"268班");
    // TreeNode *c = (TreeNode*)*list.FindByIndex(0);
    // stu->Connect(c);
    // tree.show();


    // TreeNode *one = new TreeNode((ElementType)(long)1);
    // TreeNode *two = new TreeNode((ElementType)(long)2);
    // TreeNode *three = new TreeNode((ElementType)(long)3);
    // one->Connect(tree.Getroot());
    // two->Connect(one);
    // three->Connect(one);

    // TreeNode *four = new TreeNode((ElementType)(long)4);
    // TreeNode *five = new TreeNode((ElementType)(long)5);
    // TreeNode *six = new TreeNode((ElementType)(long)6);

    // TreeNode *seven = new TreeNode((ElementType)(long)7);
    // TreeNode *eight = new TreeNode((ElementType)(long)8);
    // TreeNode *nine = new TreeNode((ElementType)(long)9);

    // four->Connect(two);
    // five->Connect(two);
    // six->Connect(two);

    // seven->Connect(three);
    // eight->Connect(three);
    // nine->Connect(three);
 
    //  tree.show();


    // DoubleLinkList list =  tree.FindByElement((ElementType)(long)6);
    // TreeNode* n = (TreeNode*) *list.FindByIndex(0);
    // n->Disconnect(n->GetParent());

    // list = tree.FindByElement((ElementType)(long)3);
    // TreeNode *p = (TreeNode*)*list.FindByIndex(0);
    // n->Connect(p);

    // tree.show();

    //std::cout<<tree.LeafSize()<<std::endl;
    return 0;
}